// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   setRight.java

package include.right;

import include.nseer_db.nseer_db_backup;
import java.io.PrintStream;
import java.sql.ResultSet;
import javax.servlet.ServletContext;

public class setRight
{

	private String cols[];
	private String ID;
	private String name;
	private String database;
	private String sql;
	private ResultSet rs;
	private ServletContext dbApplication;

	public setRight(ServletContext dbApplication)
	{
		cols = new String[1000];
		ID = "";
		name = "";
		database = "";
		sql = "";
		rs = null;
		this.dbApplication = dbApplication;
	}

	public void setRight(String unit_db_name, String ID, String uName, String dbase, String right[])
	{
		this.ID = ID;
		name = uName;
		database = dbase;
		cols = right;
		nseer_db_backup db = new nseer_db_backup(dbApplication);
		try
		{
			if (db.conn(unit_db_name))
			{
				for (int i = 0; i < cols.length; i++)
					if (cols[i] != null)
					{
						String table1 = (new StringBuilder(String.valueOf(database))).append("_tree").toString();
						String table2 = (new StringBuilder(String.valueOf(database))).append("_allright").toString();
						String table3 = (new StringBuilder(String.valueOf(database))).append("_allright_id").toString();
						sql = (new StringBuilder("select * from ")).append(table1).append(" where id='").append(cols[i]).append("'").toString();
						rs = db.executeQuery(sql);
						if (rs.next())
						{
							String sql1 = (new StringBuilder("insert into ")).append(table2).append("(tree_id,human_ID,name,main,secondary,third,fourth) values ('").append(rs.getString("tree_id")).append("','").append(ID).append("','").append(name).append("','").append(rs.getString("main")).append("','").append(rs.getString("secondary")).append("','").append(rs.getString("third")).append("','").append(rs.getString("fourth")).append("')").toString();
							db.executeUpdate(sql1);
						}
					}

			} else
			{
				System.out.println("i am sorry");
			}
		}
		catch (Exception exception) { }
		db.close();
	}
}
